package com.ruoyi.business.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.RecordPictureCar;
import com.ruoyi.business.service.IRecordPictureCarService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车辆通行记录Controller
 * 
 * @author asher
 * @date 2022-05-25
 */
@RestController
@RequestMapping("/business/record_car")
public class RecordPictureCarController extends BaseController
{
    @Autowired
    private IRecordPictureCarService recordPictureCarService;

    /**
     * 查询车辆通行记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:record_car:list')")
    @GetMapping("/list")
    public TableDataInfo list(RecordPictureCar recordPictureCar)
    {
        startPage();
        List<RecordPictureCar> list = recordPictureCarService.selectRecordPictureCarList(recordPictureCar);
        return getDataTable(list);
    }

    /**
     * 导出车辆通行记录列表
     */
    @PreAuthorize("@ss.hasPermi('business:record_car:export')")
    @Log(title = "车辆通行记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RecordPictureCar recordPictureCar)
    {
        List<RecordPictureCar> list = recordPictureCarService.selectRecordPictureCarList(recordPictureCar);
        ExcelUtil<RecordPictureCar> util = new ExcelUtil<RecordPictureCar>(RecordPictureCar.class);
        return util.exportExcel(list, "车辆通行记录数据");
    }

    /**
     * 获取车辆通行记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:record_car:query')")
    @GetMapping(value = "/{recordPictureCarId}")
    public AjaxResult getInfo(@PathVariable("recordPictureCarId") Long recordPictureCarId)
    {
        return AjaxResult.success(recordPictureCarService.selectRecordPictureCarByRecordPictureCarId(recordPictureCarId));
    }

    /**
     * 新增车辆通行记录
     */
    @PreAuthorize("@ss.hasPermi('business:record_car:add')")
    @Log(title = "车辆通行记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RecordPictureCar recordPictureCar)
    {
        return toAjax(recordPictureCarService.insertRecordPictureCar(recordPictureCar));
    }

    /**
     * 修改车辆通行记录
     */
    @PreAuthorize("@ss.hasPermi('business:record_car:edit')")
    @Log(title = "车辆通行记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RecordPictureCar recordPictureCar)
    {
        return toAjax(recordPictureCarService.updateRecordPictureCar(recordPictureCar));
    }

    /**
     * 删除车辆通行记录
     */
    @PreAuthorize("@ss.hasPermi('business:record_car:remove')")
    @Log(title = "车辆通行记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordPictureCarIds}")
    public AjaxResult remove(@PathVariable Long[] recordPictureCarIds)
    {
        return toAjax(recordPictureCarService.deleteRecordPictureCarByRecordPictureCarIds(recordPictureCarIds));
    }
}
